package com.lxf.clouduser.mapper;

import com.lxf.clouduser.bean.GroupBean;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.annotations.HighlightParameters;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 罗兴发
 * @data 2025/6/23 11:54
 * @description：es持久层
 */
@Component
public interface GroupItemRepository extends ElasticsearchRepository<GroupBean, String> {
    /**
     * 根据用户名范围查询
     * @param groupId 群号
     * @param groupName 群名称
     * @return 返回关键字高亮的结果集
     */
    @Highlight(
            fields = {@HighlightField(name = "groupId"),@HighlightField(name = "groupName")},
            parameters = @HighlightParameters(preTags = {"<span style='color:red'>"}, postTags = {"</span>"}, numberOfFragments = 0)
    )
    List<SearchHit<GroupBean>> findGroupBeanByGroupIdOrGroupName(String groupId,String groupName);

}